27 #include <QGridLayout>
31 #include <QVBoxLayout>
48 setObjectName( QLatin1String(name) );
53 mSortTypeCombo->addItem( i18nc(
"@item:inlistbox Ascending sort order",
"Ascending" ) );
54 mSortTypeCombo->addItem( i18nc(
"@item:inlistbox Descending sort order",
"Descending" ) );
56 connect( mStyleCombo, SIGNAL(activated(
int)), SIGNAL(
styleChanged(
int)) );
65 if ( pixmap.isNull() ) {
66 mPreview->setText( i18nc(
"@label",
"(No preview available.)" ) );
68 mPreview->setPixmap( pixmap );
74 mStyleCombo->addItem( name );
84 mFieldCombo->setCurrentIndex( mFields.indexOf( field ) );
89 if ( sortOrder == Qt::AscendingOrder ) {
90 mSortTypeCombo->setCurrentIndex( 0 );
92 mSortTypeCombo->setCurrentIndex( 1 );
98 if ( mFieldCombo->currentIndex() == -1 ) {
102 return mFields[ mFieldCombo->currentIndex() ];
107 return ( mSortTypeCombo->currentIndex() == 0 ? Qt::AscendingOrder : Qt::DescendingOrder );
110 void StylePage::initFieldCombo()
112 mFieldCombo->clear();
119 ContactFields::Fields::ConstIterator it;
120 ContactFields::Fields::ConstIterator end(mFields.constEnd());
121 for ( it = mFields.constBegin(); it != end; ++it ) {
126 void StylePage::initGUI()
128 setWindowTitle( i18nc(
"@title:window",
"Choose Printing Style" ) );
130 QGridLayout *topLayout =
new QGridLayout(
this );
131 topLayout->setSpacing( KDialog::spacingHint() );
132 topLayout->setMargin( KDialog::marginHint() );
136 i18nc(
"@label:textbox",
137 "What should the print look like?\n"
138 "KAddressBook has several printing styles, designed for different purposes.\n"
139 "Choose the style that suits your needs below." ),
this );
140 topLayout->addWidget( label, 0, 0, 1, 2 );
142 QGroupBox *group =
new QGroupBox( i18nc(
"@title:group",
"Sorting" ),
this );
143 QGridLayout *sortLayout =
new QGridLayout();
144 group->setLayout( sortLayout );
145 sortLayout->setSpacing( KDialog::spacingHint() );
146 sortLayout->setMargin( KDialog::marginHint() );
147 sortLayout->setAlignment( Qt::AlignTop );
149 label =
new QLabel( i18nc(
"@label:listbox",
"Criterion:" ), group );
150 sortLayout->addWidget( label, 0, 0 );
152 mFieldCombo =
new KComboBox(
false, group );
153 mFieldCombo->setToolTip(
154 i18nc(
"@info:tooltip",
"Select the primary sort field" ) );
155 mFieldCombo->setWhatsThis(
156 i18nc(
"@info:whatsthis",
157 "From this list you can select the field on which your contacts are sorted "
158 "in the print output. Use the sorting order option to determine if the "
159 "sort will be in ascending or descending order." ) );
160 sortLayout->addWidget( mFieldCombo, 0, 1 );
162 label =
new QLabel( i18nc(
"@label:listbox",
"Order:" ), group );
163 sortLayout->addWidget( label, 1, 0 );
165 mSortTypeCombo =
new KComboBox(
false, group );
166 mSortTypeCombo->setToolTip(
167 i18nc(
"@info:tooltip",
"Select the sorting order" ) );
168 mSortTypeCombo->setWhatsThis(
169 i18nc(
"@info:whatsthis",
170 "Choose if you want to sort your contacts in ascending or descending order. "
171 "Use the sorting criterion option to specify on which contact field the sorting "
172 "will be performed." ) );
173 sortLayout->addWidget( mSortTypeCombo, 1, 1 );
175 topLayout->addWidget( group, 1, 0 );
177 group =
new QGroupBox( i18nc(
"@title:group",
"Print Style" ),
this );
178 QVBoxLayout *styleLayout =
new QVBoxLayout();
179 group->setLayout( styleLayout );
180 styleLayout->setSpacing( KDialog::spacingHint() );
181 styleLayout->setMargin( KDialog::marginHint() );
183 mStyleCombo =
new KComboBox(
false, group );
184 mStyleCombo->setToolTip(
185 i18nc(
"@info:tooltip",
"Select the print style" ) );
186 mStyleCombo->setWhatsThis(
187 i18nc(
"@info:whatsthis",
188 "Choose your desired printing style. See the preview image to help you decide." ) );
190 styleLayout->addWidget( mStyleCombo );
192 mPreview =
new QLabel( group );
193 QFont font( mPreview->font() );
194 font.setPointSize( 20 );
195 mPreview->setFont( font );
196 mPreview->setScaledContents(
true );
197 mPreview->setAlignment( Qt::AlignCenter );
198 mPreview->setWordWrap(
true );
199 styleLayout->addWidget( mPreview );
201 topLayout->addWidget( group, 1, 1 );
202 topLayout->setRowStretch( 1, 1 );
207 return mStyleCombo->currentIndex();
212 mStyleCombo->setCurrentIndex( index );
215 #include "stylepage.moc"
void setPrintingStyle(int index)
Returns the sort order.
StylePage(QWidget *parent=0, const char *name=0)
void setPreview(const QPixmap &pixmap)
Set a preview image.
int printingStyle() const
Returns the sort order.
void styleChanged(int index)
This signal is emmited when the user selects a new style in the style combo box.
static bool contactFieldsNameLesser(const ContactFields::Field &field, const ContactFields::Field &otherField)
void setSortOrder(Qt::SortOrder sortOrder)
Sets the sort order.
void addStyleName(const QString &name)
Add a style name.
void setSortField(ContactFields::Field field)
Set the sort criterion field.
void clearStyleNames()
Clear the style name list.
ContactFields::Field sortField() const
Returns the sort criterion field.
Qt::SortOrder sortOrder() const
Returns the sort order.