SVN commit 1068299 by tmcguire: API fixes: rename a method and merge with another M +1 -1 transportmanagementwidget.cpp M +15 -16 transportmanager.cpp M +9 -12 transportmanager.h --- trunk/KDE/kdepimlibs/mailtransport/transportmanagementwidget.cpp #1068298:1068299 @@ -96,7 +96,7 @@ void TransportManagementWidget::Private::addClicked() { - TransportManager::self()->showNewTransportDialog( q ); + TransportManager::self()->showTransportCreationDialog( q ); } void TransportManagementWidget::Private::editClicked() --- trunk/KDE/kdepimlibs/mailtransport/transportmanager.cpp #1068298:1068299 @@ -225,29 +225,28 @@ } } -bool TransportManager::showNewTransportDialog( QWidget *parent ) +bool TransportManager::showTransportCreationDialog( QWidget *parent, + ShowCondition showCondition ) { - QPointer dialog = new AddTransportDialog( parent ); - bool accepted = ( dialog->exec() == QDialog::Accepted ); - delete dialog; - return accepted; -} + if ( showCondition == IfNoTransportExists ) { + if ( !isEmpty() ) { + return true; + } -bool TransportManager::promptCreateTransportIfNoneExists( QWidget *parent ) -{ - if ( !isEmpty() ) { - return true; - } - - const int response = KMessageBox::messageBox( parent, + const int response = KMessageBox::messageBox( parent, KMessageBox::WarningContinueCancel, i18n( "You must create an outgoing account before sending." ), i18n( "Create Account Now?" ), KGuiItem( i18n( "Create Account Now" ) ) ); - if ( response == KMessageBox::Continue ) { - return showNewTransportDialog( parent ); + if ( response != KMessageBox::Continue ) { + return false; + } } - return false; + + QPointer dialog = new AddTransportDialog( parent ); + const bool accepted = ( dialog->exec() == QDialog::Accepted ); + delete dialog; + return accepted; } bool TransportManager::configureTransport( Transport *transport, QWidget *parent ) --- trunk/KDE/kdepimlibs/mailtransport/transportmanager.h #1068298:1068299 @@ -164,26 +164,23 @@ */ void createDefaultTransport(); + /// Describes when to show the transport creation dialog + enum ShowCondition { + Always, ///< Show the transport creation dialog unconditionally + IfNoTransportExists ///< Only show the transport creation dialog if no transport currently + /// exists. Ask the user if he wants to add a transport in the other case. + }; + /** Shows a dialog for creating and configuring a new transport. @param parent Parent widget of the dialog. + @param showCondition the condition under which the dialog is shown at all @return True if a new transport has been created and configured. @since 4.4 */ - bool showNewTransportDialog( QWidget *parent ); - //TODO_AKONADI_REVIEW: rename to showTransportCreationDialog() + bool showTransportCreationDialog( QWidget *parent, ShowCondition showCondition = Always ); /** - If no transport exists, asks the user to create and configure one. - Returns true if a transport exists or the user created one. Otherwise - returns false. - @param parent Parent widget of the dialog. - @since 4.4 - */ - bool promptCreateTransportIfNoneExists( QWidget *parent ); - //TODO_AKONADI_REVIEW: merge the above methods, add enum 'Always' and 'IfNoneExists' - - /** Open a configuration dialog for an existing transport. @param transport The transport to configure. It can be a new transport, or one already managed by TransportManager.