• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

mailcommon

  • sources
  • kde-4.12
  • kdepim
  • mailcommon
  • widgets
redirectdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17  In addition, as a special exception, the copyright holders give
18  permission to link the code of this program with any edition of
19  the Qt library by Trolltech AS, Norway (or with modified versions
20  of Qt that use the same license as Qt), and distribute linked
21  combinations including the two. You must obey the GNU General
22  Public License in all respects for all of the code used other than
23  Qt. If you modify this file, you may extend this exception to
24  your version of the file, but you are not obligated to do so. If
25  you do not wish to do so, delete this exception statement from
26  your version.
27 */
28 
29 #include "redirectdialog.h"
30 #include "kernel/mailkernel.h"
31 
32 #include <messagecomposer/composer/composerlineedit.h>
33 
34 #include <messageviewer/utils/autoqpointer.h>
35 
36 #include <Akonadi/Contact/EmailAddressSelectionDialog>
37 
38 #include <KPIMUtils/Email>
39 #include <KDE/KPIMIdentities/Identity>
40 #include <KDE/KPIMIdentities/IdentityCombo>
41 #include <KDE/KPIMIdentities/IdentityManager>
42 
43 #include <KDE/Mailtransport/Transport>
44 #include <KDE/Mailtransport/TransportComboBox>
45 #include <KDE/Mailtransport/TransportManager>
46 
47 
48 #include <KIconLoader>
49 #include <KLocale>
50 #include <KMessageBox>
51 #include <KVBox>
52 
53 #include <QFrame>
54 #include <QLabel>
55 #include <QPushButton>
56 #include <QTreeView>
57 
58 using namespace MailCommon;
59 
60 class RedirectDialog::Private
61 {
62 public:
63  Private( RedirectDialog *qq, RedirectDialog::SendMode mode )
64  : q( qq ), mEditTo( 0 ), mSendMode( mode ), mComboboxIdentity( 0 ), mTransportCombobox( 0 )
65  {
66  }
67 
68  void slotUser1();
69  void slotUser2();
70  void slotAddressSelection();
71  void slotAddressChanged( const QString & );
72 
73  RedirectDialog *q;
74  MessageComposer::ComposerLineEdit *mEditTo;
75 
76  QString mResentTo;
77  RedirectDialog::SendMode mSendMode;
78  KPIMIdentities::IdentityCombo *mComboboxIdentity;
79  MailTransport::TransportComboBox *mTransportCombobox;
80 };
81 
82 void RedirectDialog::Private::slotUser1()
83 {
84  mSendMode = RedirectDialog::SendNow;
85  q->accept();
86 }
87 
88 void RedirectDialog::Private::slotUser2()
89 {
90  mSendMode = RedirectDialog::SendLater;
91  q->accept();
92 }
93 
94 void RedirectDialog::Private::slotAddressSelection()
95 {
96  MessageViewer::AutoQPointer<Akonadi::EmailAddressSelectionDialog> dlg(
97  new Akonadi::EmailAddressSelectionDialog( q ) );
98 
99  dlg->view()->view()->setSelectionMode( QAbstractItemView::MultiSelection );
100 
101  mResentTo = mEditTo->text();
102 
103  if ( dlg->exec() != KDialog::Rejected && dlg ) {
104  QStringList addresses;
105  foreach ( const Akonadi::EmailAddressSelection &selection, dlg->selectedAddresses() ) {
106  addresses << selection.quotedEmail();
107  }
108 
109  if ( !mResentTo.isEmpty() ) {
110  addresses.prepend( mResentTo );
111  }
112 
113  mEditTo->setText( addresses.join( QLatin1String(", ") ) );
114  mEditTo->setModified( true );
115  }
116 }
117 
118 void RedirectDialog::Private::slotAddressChanged( const QString &text )
119 {
120  q->enableButton( KDialog::User1, !text.isEmpty() );
121  q->enableButton( KDialog::User2, !text.isEmpty() );
122 }
123 
124 RedirectDialog::RedirectDialog( SendMode mode, QWidget *parent )
125  : KDialog( parent ), d( new Private( this, mode ) )
126 {
127  setCaption( i18n( "Redirect Message" ) );
128  setButtons( User1 | User2 | Cancel );
129  setDefaultButton( mode == SendNow ? User1 : User2 );
130 
131  QFrame *vbox = new KVBox( this );
132  setMainWidget( vbox );
133  QLabel *LabelTo = new QLabel( i18n( "Select the recipient &addresses "
134  "to redirect to:" ), vbox );
135 
136  KHBox *hbox = new KHBox( 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 );
142 
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." ) );
151 
152  connect( BtnTo, SIGNAL(clicked()), SLOT(slotAddressSelection()) );
153 
154  connect( d->mEditTo, SIGNAL(textChanged(QString)), SLOT(slotAddressChanged(QString)) );
155  LabelTo->setBuddy( BtnTo );
156  d->mEditTo->setFocus();
157 
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);
162 
163  hbox = new KHBox(vbox);
164  lab = new QLabel(i18n("Transport:"),hbox);
165  d->mTransportCombobox = new MailTransport::TransportComboBox( hbox );
166  lab->setBuddy(d->mTransportCombobox);
167 
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 );
174 }
175 
176 RedirectDialog::~RedirectDialog()
177 {
178  delete d;
179 }
180 
181 QString RedirectDialog::to() const
182 {
183  return d->mResentTo;
184 }
185 
186 RedirectDialog::SendMode RedirectDialog::sendMode() const
187 {
188  return d->mSendMode;
189 }
190 
191 int RedirectDialog::transportId() const
192 {
193  return d->mTransportCombobox->currentTransportId();
194 }
195 
196 int RedirectDialog::identity() const
197 {
198  return static_cast<int>(d->mComboboxIdentity->currentIdentity());
199 }
200 
201 void RedirectDialog::accept()
202 {
203  d->mResentTo = d->mEditTo->text();
204  if ( d->mResentTo.isEmpty() ) {
205  KMessageBox::sorry(
206  this,
207  i18n( "You cannot redirect the message without an address." ),
208  i18n( "Empty Redirection Address" ) );
209  } else {
210  done( Ok );
211  }
212 }
213 
214 #include "redirectdialog.moc"
MailCommon::RedirectDialog
A dialog to request information about message redirection from the user.
Definition: redirectdialog.h:47
MailCommon::RedirectDialog::to
QString to() const
Returns the addresses for the redirection.
Definition: redirectdialog.cpp:181
MailCommon::RedirectDialog::accept
virtual void accept()
Definition: redirectdialog.cpp:201
KernelIf
#define KernelIf
Definition: mailkernel.h:186
text
const char * text
Definition: mdnadvicedialog.cpp:52
QWidget
MailCommon::RedirectDialog::transportId
int transportId() const
Definition: redirectdialog.cpp:191
KDialog
MailCommon::RedirectDialog::SendLater
Definition: redirectdialog.h:57
MailCommon::RedirectDialog::sendMode
SendMode sendMode() const
Returns the send mode.
Definition: redirectdialog.cpp:186
MailCommon::RedirectDialog::SendMode
SendMode
Describes the send mode.
Definition: redirectdialog.h:55
redirectdialog.h
MailCommon::RedirectDialog::RedirectDialog
RedirectDialog(SendMode mode=SendNow, QWidget *parent=0)
Creates a new redirect dialog.
Definition: redirectdialog.cpp:124
mailkernel.h
MailCommon::RedirectDialog::SendNow
Definition: redirectdialog.h:56
KHBox
MailCommon::RedirectDialog::~RedirectDialog
~RedirectDialog()
Destroys the redirect dialog.
Definition: redirectdialog.cpp:176
MailCommon::RedirectDialog::identity
int identity() const
Definition: redirectdialog.cpp:196
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal