Commit 4af714f3 authored by Tobias Koenig's avatar Tobias Koenig
Browse files

Sort the contact fields on style page alphabetically

and remove the empty Undefined entry.

svn path=/trunk/KDE/kdepim/kaddressbook/; revision=1020051
parent 9687ccb1
......@@ -100,17 +100,16 @@ void PrintingWizard::slotStyleSelected( int index )
if ( index < 0 || index >= mStyleFactories.count() )
return;
//enableButton( KDialog::User1, false ); // finish button
if ( mStyle )
mStyle->hidePages();
mStyle = mStyleList.value( index );
if ( !mStyle ) {
PrintStyleFactory *factory = mStyleFactories.at( index );
kDebug(5720) <<"PrintingWizardImpl::slotStyleSelected:"
<< "creating print style"
<< factory->description();
kDebug(5720) << "PrintingWizardImpl::slotStyleSelected:"
<< "creating print style"
<< factory->description();
mStyle = factory->create();
mStyleList.insert( index, mStyle );
}
......@@ -119,12 +118,8 @@ void PrintingWizard::slotStyleSelected( int index )
mStylePage->setPreview( mStyle->preview() );
//setFinishEnabled( page( pageCount() - 1 ), true );
if ( mStyle->preferredSortField() != 0 ) {
mStylePage->setSortField( mStyle->preferredSortField() );
mStylePage->setSortOrder( mStyle->preferredSortOrder() );
}
mStylePage->setSortField( mStyle->preferredSortField() );
mStylePage->setSortOrder( mStyle->preferredSortOrder() );
}
QPrinter* PrintingWizard::printer()
......
......@@ -37,6 +37,8 @@ using namespace KABPrinting;
PrintStyle::PrintStyle( PrintingWizard* parent )
: QObject( parent ), mWizard( parent )
{
mSortField = ContactFields::GivenName;
mSortOrder = Qt::AscendingOrder;
}
PrintStyle::~PrintStyle()
......
......@@ -34,6 +34,12 @@
#include <KDialog>
#include <KLocale>
// helper method to sort contact fields by field label
static bool contactFieldsNameLesser( const ContactFields::Field &field, const ContactFields::Field &otherField )
{
return ( QString::localeAwareCompare( ContactFields::label( field ), ContactFields::label( otherField ) ) < 0 );
}
StylePage::StylePage( QWidget* parent, const char* name )
: QWidget( parent )
{
......@@ -72,7 +78,7 @@ void StylePage::clearStyleNames()
void StylePage::setSortField( ContactFields::Field field )
{
mFieldCombo->setItemText( mFieldCombo->currentIndex(), ContactFields::label( field) );
mFieldCombo->setCurrentIndex( mFields.indexOf( field ) );
}
void StylePage::setSortOrder( Qt::SortOrder sortOrder )
......@@ -86,7 +92,7 @@ void StylePage::setSortOrder( Qt::SortOrder sortOrder )
ContactFields::Field StylePage::sortField() const
{
if ( mFieldCombo->currentIndex() == -1 )
return mFields[ 0 ];
return ContactFields::GivenName;
return mFields[ mFieldCombo->currentIndex() ];
}
......@@ -101,9 +107,13 @@ void StylePage::initFieldCombo()
mFieldCombo->clear();
mFields = ContactFields::allFields();
mFields.remove( 0 ); // remove ContactFields::Undefined
qSort( mFields.begin(), mFields.end(), contactFieldsNameLesser );
ContactFields::Fields::ConstIterator it;
for ( it = mFields.constBegin(); it != mFields.constEnd(); ++it )
mFieldCombo->addItem( ContactFields::label(*it) );
mFieldCombo->addItem( ContactFields::label( *it ) );
}
void StylePage::initGUI()
......@@ -159,6 +169,7 @@ void StylePage::initGUI()
styleLayout->addWidget( mPreview );
topLayout->addWidget( group, 1, 1 );
topLayout->setRowStretch( 1, 1 );
}
#include "stylepage.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment