summaryrefslogtreecommitdiffabout
path: root/kaddressbook/emaileditwidget.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/emaileditwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/emaileditwidget.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/kaddressbook/emaileditwidget.cpp b/kaddressbook/emaileditwidget.cpp
index 0e01b02..e72face 100644
--- a/kaddressbook/emaileditwidget.cpp
+++ b/kaddressbook/emaileditwidget.cpp
@@ -144,132 +144,134 @@ EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent,
mEmailEdit = new KLineEdit( page );
label->setBuddy( mEmailEdit );
topLayout->addWidget( mEmailEdit, 0, 1 );
connect( mEmailEdit, SIGNAL( returnPressed() ), SLOT( add() ) );
connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( emailChanged() ) );
mAddButton = new QPushButton( i18n( "Add" ), page );
mAddButton->setEnabled( false );
connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) );
topLayout->addWidget( mAddButton, 0, 2 );
mEmailListBox = new QListBox( page );
// Make sure there is room for the scrollbar
mEmailListBox->setMinimumHeight( mEmailListBox->sizeHint().height() + 30 );
connect( mEmailListBox, SIGNAL( highlighted( int ) ),
SLOT( selectionChanged( int ) ) );
topLayout->addMultiCellWidget( mEmailListBox, 1, 3, 0, 1 );
mEditButton = new QPushButton( i18n( "Change" ), page );
connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) );
topLayout->addWidget( mEditButton, 1, 2 );
mRemoveButton = new QPushButton( i18n( "Remove" ), page );
connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) );
topLayout->addWidget( mRemoveButton, 2, 2 );
mStandardButton = new QPushButton( i18n( "Set Standard" ), page );
connect( mStandardButton, SIGNAL( clicked() ), SLOT( standard() ) );
topLayout->addWidget( mStandardButton, 3, 2 );
topLayout->activate();
QStringList items = list;
qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)");
//US must be fixed !!!
/*
if ( items.remove( "" ) > 0 )
mChanged = true;
else
mChanged = false;
*/
mEmailListBox->insertStringList( items );
// set default state
selectionChanged( -1 );
+ mEmailEdit->setFocus();
#ifndef KAB_EMBEDDED
KAcceleratorManager::manage( this );
#else //KAB_EMBEDDED
//US qDebug("EmailEditDialog::EmailEditDialog has to be changed");
#endif //KAB_EMBEDDED
}
EmailEditDialog::~EmailEditDialog()
{
}
QStringList EmailEditDialog::emails() const
{
QStringList emails;
for ( uint i = 0; i < mEmailListBox->count(); ++i )
emails << mEmailListBox->text( i );
return emails;
}
void EmailEditDialog::add()
{
mEmailListBox->insertItem( mEmailEdit->text() );
mEmailEdit->clear();
mEmailEdit->setFocus();
mChanged = true;
}
void EmailEditDialog::edit()
{
mEmailEdit->setText( mEmailListBox->currentText() );
+ mEmailListBox->removeItem( mEmailListBox->currentItem() );
mEmailEdit->setFocus();
}
void EmailEditDialog::remove()
{
QString address = mEmailListBox->currentText();
QString text = i18n( "<qt>Are you sure that you want to remove the email address <b>%1</b>?</qt>" ).arg( address );
QString caption = i18n( "Confirm Remove" );
if ( KMessageBox::questionYesNo( this, text, caption ) == KMessageBox::Yes ) {
mEmailListBox->removeItem( mEmailListBox->currentItem() );
mChanged = true;
}
}
bool EmailEditDialog::changed() const
{
return mChanged;
}
void EmailEditDialog::standard()
{
QString text = mEmailListBox->currentText();
mEmailListBox->removeItem( mEmailListBox->currentItem() );
mEmailListBox->insertItem( text, 0 );
mEmailListBox->setSelected( 0, true );
mChanged = true;
}
void EmailEditDialog::selectionChanged( int index )
{
bool value = ( index >= 0 ); // An item is selected
mRemoveButton->setEnabled( value );
mEditButton->setEnabled( value );
mStandardButton->setEnabled( value );
}
void EmailEditDialog::emailChanged()
{
mAddButton->setEnabled( !mEmailEdit->text().isEmpty() );
}
#ifndef KAB_EMBEDDED
#include "emaileditwidget.moc"
#endif //KAB_EMBEDDED