kmail

redirectdialog.cpp
1 /*
2  This file is part of KMail.
3  Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>
4 
5  KMail is free software; you can redistribute it and/or modify it
6  under the terms of the GNU General Public License, version 2, as
7  published by the Free Software Foundation.
8 
9  KMail is distributed in the hope that it will be useful, but
10  WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 
18  In addition, as a special exception, the copyright holders give
19  permission to link the code of this program with any edition of
20  the TQt library by Trolltech AS, Norway (or with modified versions
21  of TQt that use the same license as TQt), and distribute linked
22  combinations including the two. You must obey the GNU General
23  Public License in all respects for all of the code used other than
24  TQt. If you modify this file, you may extend this exception to
25  your version of the file, but you are not obligated to do so. If
26  you do not wish to do so, delete this exception statement from
27  your version.
28 */
29 
30 #include "redirectdialog.h"
31 
32 #include "kmkernel.h"
33 #include "kmlineeditspell.h"
34 
35 #include <libemailfunctions/email.h>
36 #include <addressesdialog.h>
37 using KPIM::AddressesDialog;
38 #include "recentaddresses.h"
39 using TDERecentAddress::RecentAddresses;
40 
41 #include <kiconloader.h>
42 #include <tdelocale.h>
43 #include <tdemessagebox.h>
44 
45 #include <tqvbox.h>
46 #include <tqhbox.h>
47 #include <tqtooltip.h>
48 #include <tqwhatsthis.h>
49 #include <tqlabel.h>
50 #include <tqpushbutton.h>
51 #include <tqstringlist.h>
52 
53 using namespace KMail;
54 
55 RedirectDialog::RedirectDialog( TQWidget *parent, const char *name,
56  bool modal, bool immediate )
57  : KDialogBase( parent, name, modal, i18n( "Redirect Message" ),
58  User1|User2|Cancel, ( immediate ? User1 : User2 ), false )
59 {
60  TQVBox *vbox = makeVBoxMainWidget();
61  mLabelTo = new TQLabel( i18n( "Select the recipient &addresses "
62  "to redirect to:" ), vbox );
63 
64  TQHBox *hbox = new TQHBox( vbox );
65  hbox->setSpacing(4);
66  mEditTo = new KMLineEdit( true, hbox, "toLine" );
67  mEditTo->setMinimumWidth( 300 );
68 
69  mBtnTo = new TQPushButton( TQString(), hbox, "toBtn" );
70  mBtnTo->setPixmap( BarIcon( "contents", TDEIcon::SizeSmall ) );
71  mBtnTo->setMinimumSize( mBtnTo->sizeHint() * 1.2 );
72  TQToolTip::add( mBtnTo, i18n("Use the Address-Selection Dialog") );
73  TQWhatsThis::add( mBtnTo, i18n("This button opens a separate dialog "
74  "where you can select recipients out "
75  "of all available addresses." ) );
76 
77  connect( mBtnTo, TQ_SIGNAL(clicked()), TQ_SLOT(slotAddrBook()) );
78 
79  connect( mEditTo, TQ_SIGNAL( textChanged ( const TQString & ) ), TQ_SLOT( slotEmailChanged( const TQString & ) ) );
80  mLabelTo->setBuddy( mBtnTo );
81  mEditTo->setFocus();
82 
83  setButtonGuiItem( User1, KGuiItem( i18n("&Send Now"), "mail-send" ) );
84  setButtonGuiItem( User2, KGuiItem( i18n("Send &Later"), "queue" ) );
85  enableButton( User1, false );
86  enableButton( User2, false );
87 }
88 
89 
90 void RedirectDialog::slotEmailChanged( const TQString & text )
91 {
92  enableButton( User1, !text.isEmpty() );
93  enableButton( User2, !text.isEmpty() );
94 }
95 
96 //-----------------------------------------------------------------------------
97 void RedirectDialog::slotUser1()
98 {
99  mImmediate = true;
100  accept();
101 }
102 
103 //-----------------------------------------------------------------------------
104 void RedirectDialog::slotUser2()
105 {
106  mImmediate = false;
107  accept();
108 }
109 
110 //-----------------------------------------------------------------------------
112 {
113  mResentTo = mEditTo->text();
114  if ( mResentTo.isEmpty() ) {
115  KMessageBox::sorry( this,
116  i18n("You cannot redirect the message without an address."),
117  i18n("Empty Redirection Address") );
118  }
119  else done( Ok );
120 }
121 
122 
123 //-----------------------------------------------------------------------------
125 {
126  AddressesDialog dlg( this );
127 
128  mResentTo = mEditTo->text();
129  if ( !mResentTo.isEmpty() ) {
130  TQStringList lst = KPIM::splitEmailAddrList( mResentTo );
131  dlg.setSelectedTo( lst );
132  }
133 
134  dlg.setRecentAddresses(
135  RecentAddresses::self( KMKernel::config() )->tdeabcAddresses() );
136 
137  // Make it impossible to specify Cc or Bcc addresses as we support
138  // only the Redirect-To header!
139  dlg.setShowCC( false );
140  dlg.setShowBCC( false );
141 
142  if (dlg.exec()==TQDialog::Rejected) return;
143 
144  mEditTo->setText( dlg.to().join(", ") );
145  mEditTo->setEdited( true );
146 }
147 
148 
149 #include "redirectdialog.moc"
void slotAddrBook()
Open addressbook editor dialog.
RedirectDialog(TQWidget *parent=0, const char *name=0, bool modal=false, bool immediate=true)
Constructor.
void accept()
Evaluate the settings, an empty To field is not allowed.
folderdiaquotatab.h
Definition: aboutdata.cpp:40