diff --git a/recipientseditor.cpp b/recipientseditor.cpp index 183a2a06b..8ac16583a 100644 --- a/recipientseditor.cpp +++ b/recipientseditor.cpp @@ -170,6 +170,7 @@ RecipientLine::RecipientLine( QWidget *parent ) connect( mEdit, SIGNAL( rightPressed() ), SIGNAL( rightPressed() ) ); connect( mEdit, SIGNAL( leftPressed() ), mCombo, SLOT( setFocus() ) ); + connect( mEdit, SIGNAL( editingFinished() ), SLOT( slotEditingFinished() ) ); connect( mEdit, SIGNAL( clearButtonClicked() ), SLOT( slotPropagateDeletion() ) ); connect( mCombo, SIGNAL( rightPressed() ), mEdit, SLOT( setFocus() ) ); @@ -271,6 +272,13 @@ void RecipientLine::slotPropagateDeletion() emit deleteLine( this ); } +void RecipientLine::slotEditingFinished() +{ + if ( mEdit->text().isEmpty() ) { + emit deleteLine( this ); + } +} + void RecipientLine::keyPressEvent( QKeyEvent *ev ) { if ( ev->key() == Qt::Key_Up ) { @@ -490,7 +498,7 @@ void RecipientsView::slotDecideLineDeletion( RecipientLine *line ) mModified = true; if ( mLines.count() == 1 ) { line->clear(); - } else { + } else if ( mLines.indexOf( line ) != mLines.count() - 1 ) { mCurDelLine = line; QTimer::singleShot( 0, this, SLOT( slotDeleteLine( ) ) ); } @@ -504,13 +512,15 @@ void RecipientsView::slotDeleteLine() RecipientLine *line = mCurDelLine; int pos = mLines.indexOf( line ); - int newPos; - if ( pos == 0 ) newPos = pos + 1; - else newPos = pos - 1; + if ( mCurDelLine->isActive() ) { + int newPos; + if ( pos == 0 ) newPos = pos + 1; + else newPos = pos - 1; - // if there is something left to activate, do so - if ( mLines.at( newPos ) ) - mLines.at( newPos )->activate(); + // if there is something left to activate, do so + if ( mLines.at( newPos ) ) + mLines.at( newPos )->activate(); + } mLines.removeAll( line ); line->setParent( 0 ); diff --git a/recipientseditor.h b/recipientseditor.h index ed7ddeb9b..d9e2ef4e3 100644 --- a/recipientseditor.h +++ b/recipientseditor.h @@ -158,6 +158,7 @@ class RecipientLine : public QWidget void analyzeLine( const QString & ); void slotFocusUp(); void slotFocusDown(); + void slotEditingFinished(); void slotPropagateDeletion(); void slotTypeModified();