25 #include <tqbuttongroup.h>
29 #include <tqradiobutton.h>
31 #include <kcombobox.h>
33 #include <tdelocale.h>
35 #include "stylepage.h"
37 StylePage::StylePage( TDEABC::AddressBook *ab, TQWidget* parent,
const char* name )
38 : TQWidget( parent, name ), mAddressBook( ab )
44 mSortTypeCombo->insertItem( i18n(
"Ascending" ) );
45 mSortTypeCombo->insertItem( i18n(
"Descending" ) );
47 connect( mStyleCombo, TQ_SIGNAL( activated(
int ) ), TQ_SIGNAL( styleChanged(
int ) ) );
50 StylePage::~StylePage()
54 void StylePage::setPreview(
const TQPixmap &pixmap )
56 if ( pixmap.isNull() )
57 mPreview->setText( i18n(
"(No preview available.)" ) );
59 mPreview->setPixmap( pixmap );
62 void StylePage::addStyleName(
const TQString &name )
64 mStyleCombo->insertItem( name );
67 void StylePage::clearStyleNames()
72 void StylePage::setSortField( TDEABC::Field *field )
74 mFieldCombo->setCurrentText( field->label() );
77 void StylePage::setSortAscending(
bool value )
80 mSortTypeCombo->setCurrentItem( 0 );
82 mSortTypeCombo->setCurrentItem( 1 );
85 TDEABC::Field* StylePage::sortField()
87 if ( mFieldCombo->currentItem() == -1 )
90 return mFields[ mFieldCombo->currentItem() ];
93 bool StylePage::sortAscending()
95 return ( mSortTypeCombo->currentItem() == 0 );
98 void StylePage::initFieldCombo()
103 mFieldCombo->clear();
105 mFields = mAddressBook->fields( TDEABC::Field::All );
106 TDEABC::Field::List::ConstIterator it;
107 for ( it = mFields.begin(); it != mFields.end(); ++it )
108 mFieldCombo->insertItem( (*it)->label() );
111 void StylePage::initGUI()
113 setCaption( i18n(
"Choose Printing Style" ) );
115 TQGridLayout *topLayout =
new TQGridLayout(
this, 2, 2, KDialog::marginHint(),
116 KDialog::spacingHint() );
118 TQLabel *label =
new TQLabel( i18n(
"What should the print look like?\n"
119 "KAddressBook has several printing styles, designed for different purposes.\n"
120 "Choose the style that suits your needs below." ),
this );
121 topLayout->addMultiCellWidget( label, 0, 0, 0, 1 );
123 TQButtonGroup *group =
new TQButtonGroup( i18n(
"Sorting" ),
this );
124 group->setColumnLayout( 0, TQt::Vertical );
125 TQGridLayout *sortLayout =
new TQGridLayout( group->layout(), 2, 2,
126 KDialog::spacingHint() );
127 sortLayout->setAlignment( TQt::AlignTop );
129 label =
new TQLabel( i18n(
"Criterion:" ), group );
130 sortLayout->addWidget( label, 0, 0 );
132 mFieldCombo =
new KComboBox(
false, group );
133 sortLayout->addWidget( mFieldCombo, 0, 1 );
135 label =
new TQLabel( i18n(
"Order:" ), group );
136 sortLayout->addWidget( label, 1, 0 );
138 mSortTypeCombo =
new KComboBox(
false, group );
139 sortLayout->addWidget( mSortTypeCombo, 1, 1 );
141 topLayout->addWidget( group, 1, 0 );
143 group =
new TQButtonGroup( i18n(
"Print Style" ),
this );
144 group->setColumnLayout( 0, TQt::Vertical );
145 TQVBoxLayout *styleLayout =
new TQVBoxLayout( group->layout(),
146 KDialog::spacingHint() );
148 mStyleCombo =
new KComboBox(
false, group );
149 styleLayout->addWidget( mStyleCombo );
151 mPreview =
new TQLabel( group );
152 TQFont font( mPreview->font() );
153 font.setPointSize( 20 );
154 mPreview->setFont( font );
155 mPreview->setScaledContents(
true );
156 mPreview->setAlignment(
int( TQLabel::WordBreak | TQLabel::AlignCenter ) );
157 styleLayout->addWidget( mPreview );
159 topLayout->addWidget( group, 1, 1 );
162 #include "stylepage.moc"