00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "redirectdialog.h"
00031
00032 #include "kmkernel.h"
00033 #include "kmlineeditspell.h"
00034
00035 #include <libemailfunctions/email.h>
00036 #include <addressesdialog.h>
00037 using KPIM::AddressesDialog;
00038 #include "recentaddresses.h"
00039 using KRecentAddress::RecentAddresses;
00040
00041 #include <kiconloader.h>
00042 #include <klocale.h>
00043 #include <kmessagebox.h>
00044
00045 #include <tqvbox.h>
00046 #include <tqhbox.h>
00047 #include <tqtooltip.h>
00048 #include <tqwhatsthis.h>
00049 #include <tqlabel.h>
00050 #include <tqpushbutton.h>
00051 #include <tqstringlist.h>
00052
00053 using namespace KMail;
00054
00055 RedirectDialog::RedirectDialog( TQWidget *parent, const char *name,
00056 bool modal, bool immediate )
00057 : KDialogBase( parent, name, modal, i18n( "Redirect Message" ),
00058 User1|User2|Cancel, ( immediate ? User1 : User2 ), false )
00059 {
00060 TQVBox *vbox = makeVBoxMainWidget();
00061 mLabelTo = new TQLabel( i18n( "Select the recipient &addresses "
00062 "to redirect to:" ), vbox );
00063
00064 TQHBox *hbox = new TQHBox( vbox );
00065 hbox->setSpacing(4);
00066 mEditTo = new KMLineEdit( true, hbox, "toLine" );
00067 mEditTo->setMinimumWidth( 300 );
00068
00069 mBtnTo = new TQPushButton( TQString(), hbox, "toBtn" );
00070 mBtnTo->setPixmap( BarIcon( "contents", KIcon::SizeSmall ) );
00071 mBtnTo->setMinimumSize( mBtnTo->sizeHint() * 1.2 );
00072 TQToolTip::add( mBtnTo, i18n("Use the Address-Selection Dialog") );
00073 TQWhatsThis::add( mBtnTo, i18n("This button opens a separate dialog "
00074 "where you can select recipients out "
00075 "of all available addresses." ) );
00076
00077 connect( mBtnTo, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddrBook()) );
00078
00079 connect( mEditTo, TQT_SIGNAL( textChanged ( const TQString & ) ), TQT_SLOT( slotEmailChanged( const TQString & ) ) );
00080 mLabelTo->setBuddy( mBtnTo );
00081 mEditTo->setFocus();
00082
00083 setButtonGuiItem( User1, KGuiItem( i18n("&Send Now"), "mail_send" ) );
00084 setButtonGuiItem( User2, KGuiItem( i18n("Send &Later"), "queue" ) );
00085 enableButton( User1, false );
00086 enableButton( User2, false );
00087 }
00088
00089
00090 void RedirectDialog::slotEmailChanged( const TQString & text )
00091 {
00092 enableButton( User1, !text.isEmpty() );
00093 enableButton( User2, !text.isEmpty() );
00094 }
00095
00096
00097 void RedirectDialog::slotUser1()
00098 {
00099 mImmediate = true;
00100 accept();
00101 }
00102
00103
00104 void RedirectDialog::slotUser2()
00105 {
00106 mImmediate = false;
00107 accept();
00108 }
00109
00110
00111 void RedirectDialog::accept()
00112 {
00113 mResentTo = mEditTo->text();
00114 if ( mResentTo.isEmpty() ) {
00115 KMessageBox::sorry( this,
00116 i18n("You cannot redirect the message without an address."),
00117 i18n("Empty Redirection Address") );
00118 }
00119 else done( Ok );
00120 }
00121
00122
00123
00124 void RedirectDialog::slotAddrBook()
00125 {
00126 AddressesDialog dlg( this );
00127
00128 mResentTo = mEditTo->text();
00129 if ( !mResentTo.isEmpty() ) {
00130 TQStringList lst = KPIM::splitEmailAddrList( mResentTo );
00131 dlg.setSelectedTo( lst );
00132 }
00133
00134 dlg.setRecentAddresses(
00135 RecentAddresses::self( KMKernel::config() )->kabcAddresses() );
00136
00137
00138
00139 dlg.setShowCC( false );
00140 dlg.setShowBCC( false );
00141
00142 if (dlg.exec()==TQDialog::Rejected) return;
00143
00144 mEditTo->setText( dlg.to().join(", ") );
00145 mEditTo->setEdited( true );
00146 }
00147
00148
00149 #include "redirectdialog.moc"