Commit 650147fb authored by Volker Krause's avatar Volker Krause
Browse files

keep selection on update if possible

svn path=/trunk/KDE/kdepim/mailtransport/; revision=620483
parent 2a19d195
......@@ -21,9 +21,7 @@ TransportManager
TransportComboBox
-----------------
- select item by transport id
- handle ad-hoc transports (see identity dialog)
- keep selection on update if possible
Transport
---------
......
......@@ -34,14 +34,24 @@ TransportComboBox::TransportComboBox(QWidget * parent) :
int TransportComboBox::currentTransportId() const
{
if ( currentIndex() == 0 || count() == 0 )
return 0; // default
return TransportManager::self()->transportIds().at( currentIndex() - 1 );
if( currentIndex() > 0 && currentIndex() <= mTransports.count() )
return mTransports.at( currentIndex() );
return 0;
}
void TransportComboBox::setCurrentTransport(int transportId)
{
int i = mTransports.indexOf( transportId );
if ( i >= 0 && i <= count() )
setCurrentIndex( i );
}
void TransportComboBox::fillComboBox()
{
int oldTransport = currentTransportId();
clear();
mTransports.clear();
if ( !TransportManager::self()->isEmpty() ) {
QString defName = TransportManager::self()->defaultTransportName();
if ( defName.isEmpty() )
......@@ -49,7 +59,11 @@ void TransportComboBox::fillComboBox()
else
addItem( i18n( "Default (%1)", defName ) );
addItems( TransportManager::self()->transportNames() );
mTransports << 0;
mTransports << TransportManager::self()->transportIds();
}
setCurrentTransport( oldTransport );
}
#include "transportcombobox.moc"
......@@ -44,9 +44,18 @@ class MAILTRANSPORT_EXPORT TransportComboBox : public KComboBox
*/
int currentTransportId() const;
/**
Selects the given transport.
@param transportId The transport identifier.
*/
void setCurrentTransport( int transportId );
private slots:
void fillComboBox();
private:
QList<int> mTransports;
};
}
......
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