32 #include <messagecomposer/composer/composerlineedit.h>
34 #include <messageviewer/utils/autoqpointer.h>
36 #include <Akonadi/Contact/EmailAddressSelectionDialog>
38 #include <KPIMUtils/Email>
39 #include <KDE/KPIMIdentities/Identity>
40 #include <KDE/KPIMIdentities/IdentityCombo>
41 #include <KDE/KPIMIdentities/IdentityManager>
43 #include <KDE/Mailtransport/Transport>
44 #include <KDE/Mailtransport/TransportComboBox>
45 #include <KDE/Mailtransport/TransportManager>
48 #include <KIconLoader>
50 #include <KMessageBox>
55 #include <QPushButton>
58 using namespace MailCommon;
60 class RedirectDialog::Private
64 : q( qq ), mEditTo( 0 ), mSendMode( mode ), mComboboxIdentity( 0 ), mTransportCombobox( 0 )
70 void slotAddressSelection();
71 void slotAddressChanged(
const QString & );
74 MessageComposer::ComposerLineEdit *mEditTo;
78 KPIMIdentities::IdentityCombo *mComboboxIdentity;
79 MailTransport::TransportComboBox *mTransportCombobox;
82 void RedirectDialog::Private::slotUser1()
88 void RedirectDialog::Private::slotUser2()
94 void RedirectDialog::Private::slotAddressSelection()
96 MessageViewer::AutoQPointer<Akonadi::EmailAddressSelectionDialog> dlg(
97 new Akonadi::EmailAddressSelectionDialog( q ) );
99 dlg->view()->view()->setSelectionMode( QAbstractItemView::MultiSelection );
101 mResentTo = mEditTo->text();
103 if ( dlg->exec() != KDialog::Rejected && dlg ) {
104 QStringList addresses;
105 foreach (
const Akonadi::EmailAddressSelection &selection, dlg->selectedAddresses() ) {
106 addresses << selection.quotedEmail();
109 if ( !mResentTo.isEmpty() ) {
110 addresses.prepend( mResentTo );
113 mEditTo->setText( addresses.join( QLatin1String(
", ") ) );
114 mEditTo->setModified(
true );
118 void RedirectDialog::Private::slotAddressChanged(
const QString &
text )
120 q->enableButton( KDialog::User1, !text.isEmpty() );
121 q->enableButton( KDialog::User2, !text.isEmpty() );
125 :
KDialog( parent ), d( new Private( this, mode ) )
127 setCaption( i18n(
"Redirect Message" ) );
128 setButtons( User1 | User2 | Cancel );
129 setDefaultButton( mode ==
SendNow ? User1 : User2 );
131 QFrame *vbox =
new KVBox(
this );
132 setMainWidget( vbox );
133 QLabel *LabelTo =
new QLabel( i18n(
"Select the recipient &addresses "
134 "to redirect to:" ), vbox );
137 hbox->setSpacing( 4 );
138 d->mEditTo =
new MessageComposer::ComposerLineEdit(
true, hbox );
139 d->mEditTo->setRecentAddressConfig(
KernelIf->config().data() );
140 d->mEditTo->setMinimumWidth( 300 );
141 d->mEditTo->setClearButtonShown(
true );
143 QPushButton *BtnTo =
new QPushButton( QString(), hbox );
144 BtnTo->setIcon( KIcon( QLatin1String(
"help-contents") ) );
145 BtnTo->setIconSize( QSize( KIconLoader::SizeSmall, KIconLoader::SizeSmall ) );
146 BtnTo->setMinimumSize( BtnTo->sizeHint() * 1.2 );
147 BtnTo->setToolTip( i18n(
"Use the Address-Selection Dialog" ) );
148 BtnTo->setWhatsThis( i18n(
"This button opens a separate dialog "
149 "where you can select recipients out "
150 "of all available addresses." ) );
152 connect( BtnTo, SIGNAL(clicked()), SLOT(slotAddressSelection()) );
154 connect( d->mEditTo, SIGNAL(textChanged(QString)), SLOT(slotAddressChanged(QString)) );
155 LabelTo->setBuddy( BtnTo );
156 d->mEditTo->setFocus();
158 hbox =
new KHBox( vbox );
159 QLabel *lab =
new QLabel(i18n(
"Identity:"),hbox);
160 d->mComboboxIdentity =
new KPIMIdentities::IdentityCombo(
KernelIf->identityManager(),hbox);
161 lab->setBuddy(d->mComboboxIdentity);
163 hbox =
new KHBox(vbox);
164 lab =
new QLabel(i18n(
"Transport:"),hbox);
165 d->mTransportCombobox =
new MailTransport::TransportComboBox( hbox );
166 lab->setBuddy(d->mTransportCombobox);
168 setButtonGuiItem( User1, KGuiItem( i18n(
"&Send Now" ), QLatin1String(
"mail-send") ) );
169 setButtonGuiItem( User2, KGuiItem( i18n(
"Send &Later" ), QLatin1String(
"mail-queue") ) );
170 connect(
this, SIGNAL(user1Clicked()),
this, SLOT(slotUser1()) );
171 connect(
this, SIGNAL(user2Clicked()),
this, SLOT(slotUser2()) );
172 enableButton( User1,
false );
173 enableButton( User2,
false );
193 return d->mTransportCombobox->currentTransportId();
198 return static_cast<int>(d->mComboboxIdentity->currentIdentity());
203 d->mResentTo = d->mEditTo->text();
204 if ( d->mResentTo.isEmpty() ) {
207 i18n(
"You cannot redirect the message without an address." ),
208 i18n(
"Empty Redirection Address" ) );
214 #include "redirectdialog.moc"
A dialog to request information about message redirection from the user.
QString to() const
Returns the addresses for the redirection.
SendMode sendMode() const
Returns the send mode.
SendMode
Describes the send mode.
RedirectDialog(SendMode mode=SendNow, QWidget *parent=0)
Creates a new redirect dialog.
~RedirectDialog()
Destroys the redirect dialog.