20 #include "addtransportdialog.h"
21 #include "transport.h"
22 #include "transportconfigwidget.h"
23 #include "transportmanager.h"
24 #include "transporttype.h"
25 #include "ui_addtransportdialog.h"
30 #include <akonadi/agentinstance.h>
31 #include <akonadi/agentinstancecreatejob.h>
33 using namespace MailTransport;
38 class AddTransportDialog::Private
55 void updateOkButton();
61 ::Ui::AddTransportDialog ui;
65 void AddTransportDialog::Private::writeConfig()
67 KConfigGroup group( KGlobal::config(),
"AddTransportDialog" );
68 group.writeEntry(
"Size", q->size() );
71 void AddTransportDialog::Private::readConfig()
73 KConfigGroup group( KGlobal::config(),
"AddTransportDialog" );
74 const QSize sizeDialog = group.readEntry(
"Size",
QSize(400,300) );
76 q->resize( sizeDialog );
80 TransportType AddTransportDialog::Private::selectedType()
const
89 void AddTransportDialog::Private::doubleClicked()
91 if (selectedType().isValid() && !ui.name->text().trimmed().isEmpty()) {
96 void AddTransportDialog::Private::updateOkButton()
99 q->enableButtonOk( selectedType().isValid() && !ui.name->text().trimmed().isEmpty() );
103 : KDialog( parent ), d( new Private( this ) )
108 d->ui.setupUi( widget );
109 setMainWidget( widget );
110 setCaption( i18n(
"Create Outgoing Account" ) );
111 setButtons( Ok|Cancel );
112 enableButtonOk(
false );
113 setButtonText( Ok, i18nc(
"create and configure a mail transport",
"Create and Configure" ) );
115 #ifdef KDEPIM_MOBILE_UI
116 d->ui.descLabel->hide();
117 d->ui.setDefault->hide();
128 d->ui.typeListView->resizeColumnToContents( 0 );
130 d->ui.typeListView->setFocus();
133 connect( d->ui.typeListView, SIGNAL(itemClicked(
QTreeWidgetItem*,
int)),
134 this, SLOT(updateOkButton()) );
135 connect( d->ui.typeListView, SIGNAL(itemSelectionChanged()),
136 this, SLOT(updateOkButton()) );
137 connect( d->ui.typeListView, SIGNAL(itemDoubleClicked(
QTreeWidgetItem*,
int)),
138 this, SLOT(doubleClicked()) );
139 connect( d->ui.name, SIGNAL(textChanged(
QString)),
140 this, SLOT(updateOkButton()) );
150 void AddTransportDialog::accept()
152 if ( !d->selectedType().isValid() ) {
159 if ( d->selectedType().type() == Transport::EnumType::Akonadi ) {
161 using namespace Akonadi;
162 AgentInstanceCreateJob *cjob =
new AgentInstanceCreateJob( d->selectedType().agentType() );
163 if ( !cjob->exec() ) {
164 kWarning() <<
"Failed to create agent instance of type"
165 << d->selectedType().agentType().identifier();
168 transport->setHost( cjob->instance().identifier() );
170 transport->setName( d->ui.name->text().trimmed() );
175 #ifndef KDEPIM_MOBILE_UI
176 if ( d->ui.setDefault->isChecked() ) {
184 #include "moc_addtransportdialog.cpp"
A representation of a transport type.
QString name() const
Returns the i18n'ed name of the transport type.
void addTransport(Transport *transport)
Adds the given transport.
Q_SCRIPTABLE void setDefaultTransport(int id)
Sets the default transport.
static TransportManager * self()
Returns the TransportManager instance.
void setTransportType(const TransportType &type)
Sets the type of this transport.
QString description() const
Returns a description of the transport type.
Transport * createTransport() const
Creates a new, empty Transport object.
QVariant fromValue(const T &value)
void forceUniqueName()
Makes sure the transport has a unique name.
AddTransportDialog(QWidget *parent=0)
Creates a new AddTransportDialog.
void setText(int column, const QString &text)
Represents the settings of a specific mail transport.
virtual ~AddTransportDialog()
Destroys the AddTransportDialog.