stylepage.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <qbuttongroup.h>
00026 #include <qlabel.h>
00027 #include <qlayout.h>
00028 #include <qpixmap.h>
00029 #include <qradiobutton.h>
00030
00031 #include <kcombobox.h>
00032 #include <kdialog.h>
00033 #include <klocale.h>
00034
00035 #include "stylepage.h"
00036
00037 StylePage::StylePage( KABC::AddressBook *ab, QWidget* parent, const char* name )
00038 : QWidget( parent, name ), mAddressBook( ab )
00039 {
00040 initGUI();
00041
00042 initFieldCombo();
00043
00044 mSortTypeCombo->insertItem( i18n( "Ascending" ) );
00045 mSortTypeCombo->insertItem( i18n( "Descending" ) );
00046
00047 connect( mStyleCombo, SIGNAL( activated( int ) ), SIGNAL( styleChanged( int ) ) );
00048 }
00049
00050 StylePage::~StylePage()
00051 {
00052 }
00053
00054 void StylePage::setPreview( const QPixmap &pixmap )
00055 {
00056 if ( pixmap.isNull() )
00057 mPreview->setText( i18n( "(No preview available.)" ) );
00058 else
00059 mPreview->setPixmap( pixmap );
00060 }
00061
00062 void StylePage::addStyleName( const QString &name )
00063 {
00064 mStyleCombo->insertItem( name );
00065 }
00066
00067 void StylePage::clearStyleNames()
00068 {
00069 mStyleCombo->clear();
00070 }
00071
00072 void StylePage::setSortField( KABC::Field *field )
00073 {
00074 mFieldCombo->setCurrentText( field->label() );
00075 }
00076
00077 void StylePage::setSortAscending( bool value )
00078 {
00079 if ( value )
00080 mSortTypeCombo->setCurrentItem( 0 );
00081 else
00082 mSortTypeCombo->setCurrentItem( 1 );
00083 }
00084
00085 KABC::Field* StylePage::sortField()
00086 {
00087 if ( mFieldCombo->currentItem() == -1 )
00088 return mFields[ 0 ];
00089
00090 return mFields[ mFieldCombo->currentItem() ];
00091 }
00092
00093 bool StylePage::sortAscending()
00094 {
00095 return ( mSortTypeCombo->currentItem() == 0 );
00096 }
00097
00098 void StylePage::initFieldCombo()
00099 {
00100 if ( !mAddressBook )
00101 return;
00102
00103 mFieldCombo->clear();
00104
00105 mFields = mAddressBook->fields( KABC::Field::All );
00106 KABC::Field::List::Iterator it;
00107 for ( it = mFields.begin(); it != mFields.end(); ++it )
00108 mFieldCombo->insertItem( (*it)->label() );
00109 }
00110
00111 void StylePage::initGUI()
00112 {
00113 setCaption( i18n( "Choose Printing Style" ) );
00114
00115 QGridLayout *topLayout = new QGridLayout( this, 2, 2, KDialog::marginHint(),
00116 KDialog::spacingHint() );
00117
00118 QLabel *label = new QLabel( i18n( "What should the print look like?\n"
00119 "KAddressBook has several printing styles, designed for different purposes.\n"
00120 "Choose the style that suits your needs below." ), this );
00121 topLayout->addMultiCellWidget( label, 0, 0, 0, 1 );
00122
00123 QButtonGroup *group = new QButtonGroup( i18n( "Sorting" ), this );
00124 group->setColumnLayout( 0, Qt::Vertical );
00125 QGridLayout *sortLayout = new QGridLayout( group->layout(), 2, 2,
00126 KDialog::spacingHint() );
00127 sortLayout->setAlignment( Qt::AlignTop );
00128
00129 label = new QLabel( i18n( "Criterion:" ), group );
00130 sortLayout->addWidget( label, 0, 0 );
00131
00132 mFieldCombo = new KComboBox( false, group );
00133 sortLayout->addWidget( mFieldCombo, 0, 1 );
00134
00135 label = new QLabel( i18n( "Order:" ), group );
00136 sortLayout->addWidget( label, 1, 0 );
00137
00138 mSortTypeCombo = new KComboBox( false, group );
00139 sortLayout->addWidget( mSortTypeCombo, 1, 1 );
00140
00141 topLayout->addWidget( group, 1, 0 );
00142
00143 group = new QButtonGroup( i18n( "Print Style" ), this );
00144 group->setColumnLayout( 0, Qt::Vertical );
00145 QVBoxLayout *styleLayout = new QVBoxLayout( group->layout(),
00146 KDialog::spacingHint() );
00147
00148 mStyleCombo = new KComboBox( false, group );
00149 styleLayout->addWidget( mStyleCombo );
00150
00151 mPreview = new QLabel( group );
00152 QFont font( mPreview->font() );
00153 font.setPointSize( 20 );
00154 mPreview->setFont( font );
00155 mPreview->setScaledContents( true );
00156 mPreview->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
00157 styleLayout->addWidget( mPreview );
00158
00159 topLayout->addWidget( group, 1, 1 );
00160 }
00161
00162 #include "stylepage.moc"
This file is part of the documentation for kaddressbook Library Version 3.2.2.