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

mailcommon

  • sources
  • kde-4.14
  • kdepim
  • mailcommon
  • widgets
redirectdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>
3  Copyright (c) 2014-2015 Laurent Montel <montel@kde.org>
4 
5  This program 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  This program 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 Qt library by Trolltech AS, Norway (or with modified versions
21  of Qt that use the same license as Qt), 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  Qt. 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 #include "kernel/mailkernel.h"
32 
33 #include "redirectwidget.h"
34 
35 #include <KPIMUtils/Email>
36 #include <KDE/KPIMIdentities/Identity>
37 #include <KDE/KPIMIdentities/IdentityCombo>
38 #include <KDE/KPIMIdentities/IdentityManager>
39 
40 #include <KDE/Mailtransport/Transport>
41 #include <KDE/Mailtransport/TransportComboBox>
42 #include <KDE/Mailtransport/TransportManager>
43 
44 
45 #include <KIconLoader>
46 #include <KLocale>
47 #include <KMessageBox>
48 #include <KVBox>
49 
50 #include <QFrame>
51 #include <QLabel>
52 #include <QPushButton>
53 #include <QTreeView>
54 #include <QHBoxLayout>
55 #include <QFormLayout>
56 
57 using namespace MailCommon;
58 
59 
60 
61 class RedirectDialog::Private
62 {
63 public:
64  Private( RedirectDialog *qq, RedirectDialog::SendMode mode )
65  : q( qq ),
66  mEditTo( 0 ),
67  mEditCc( 0 ),
68  mEditBcc( 0 ),
69  mSendMode( mode ),
70  mComboboxIdentity( 0 ),
71  mTransportCombobox( 0 )
72  {
73  }
74  enum TypeAddress {
75  ResendTo,
76  ResendCc,
77  ResendBcc
78  };
79 
80  void slotUser1();
81  void slotUser2();
82  void slotAddressChanged( const QString & );
83  QString redirectLabelType(TypeAddress type) const;
84  RedirectDialog *q;
85  RedirectWidget *mEditTo;
86  RedirectWidget *mEditCc;
87  RedirectWidget *mEditBcc;
88 
89  RedirectDialog::SendMode mSendMode;
90  KPIMIdentities::IdentityCombo *mComboboxIdentity;
91  MailTransport::TransportComboBox *mTransportCombobox;
92 };
93 
94 QString RedirectDialog::Private::redirectLabelType(TypeAddress type) const
95 {
96  QString label;
97  switch(type) {
98  case ResendTo:
99  label = i18n("Resend-To:");
100  break;
101  case ResendCc:
102  label = i18n("Resend-Cc:");
103  break;
104  case ResendBcc:
105  label = i18n("Resend-Bcc:");
106  break;
107  }
108  return label;
109 }
110 
111 void RedirectDialog::Private::slotUser1()
112 {
113  mSendMode = RedirectDialog::SendNow;
114  q->accept();
115 }
116 
117 void RedirectDialog::Private::slotUser2()
118 {
119  mSendMode = RedirectDialog::SendLater;
120  q->accept();
121 }
122 
123 void RedirectDialog::Private::slotAddressChanged( const QString &text )
124 {
125  const bool textIsNotEmpty(!text.trimmed().isEmpty());
126  q->enableButton( KDialog::User1, textIsNotEmpty );
127  q->enableButton( KDialog::User2, textIsNotEmpty );
128 }
129 
130 RedirectDialog::RedirectDialog( SendMode mode, QWidget *parent )
131  : KDialog( parent ), d( new Private( this, mode ) )
132 {
133  setCaption( i18n( "Redirect Message" ) );
134  setButtons( User1 | User2 | Cancel );
135  setDefaultButton( mode == SendNow ? User1 : User2 );
136 
137  QWidget *mainWidget = new QWidget;
138  setMainWidget(mainWidget);
139  QVBoxLayout *mainLayout = new QVBoxLayout;
140  mainWidget->setLayout(mainLayout);
141  mainLayout->setSpacing(0);
142  QLabel *LabelTo = new QLabel( i18n( "Select the recipient addresses to redirect:" ));
143  mainLayout->addWidget(LabelTo);
144 
145  QFormLayout *formLayout = new QFormLayout;
146  mainLayout->addLayout(formLayout);
147 
148  d->mEditTo = new RedirectWidget;
149  mainLayout->addWidget(d->mEditTo);
150  formLayout->addRow(d->redirectLabelType(RedirectDialog::Private::ResendTo), d->mEditTo);
151 
152  connect( d->mEditTo, SIGNAL(addressChanged(QString)), SLOT(slotAddressChanged(QString)) );
153 
154  d->mEditCc = new RedirectWidget;
155  formLayout->addRow(d->redirectLabelType(RedirectDialog::Private::ResendCc), d->mEditCc);
156  d->mEditBcc = new RedirectWidget;
157  formLayout->addRow(d->redirectLabelType(RedirectDialog::Private::ResendBcc), d->mEditBcc);
158  d->mEditTo->setFocus();
159 
160  QHBoxLayout *hbox = new QHBoxLayout;
161  mainLayout->addLayout(hbox);
162  QLabel *lab = new QLabel(i18n("Identity:"));
163  hbox->addWidget(lab);
164  d->mComboboxIdentity = new KPIMIdentities::IdentityCombo(KernelIf->identityManager());
165  hbox->addWidget(d->mComboboxIdentity);
166  lab->setBuddy(d->mComboboxIdentity);
167 
168  hbox = new QHBoxLayout;
169  mainLayout->addLayout(hbox);
170  lab = new QLabel(i18n("Transport:"));
171  hbox->addWidget(lab);
172  d->mTransportCombobox = new MailTransport::TransportComboBox;
173  hbox->addWidget(d->mTransportCombobox);
174  lab->setBuddy(d->mTransportCombobox);
175 
176  setButtonGuiItem( User1, KGuiItem( i18n( "&Send Now" ), QLatin1String("mail-send") ) );
177  setButtonGuiItem( User2, KGuiItem( i18n( "Send &Later" ), QLatin1String("mail-queue") ) );
178  connect( this, SIGNAL(user1Clicked()), this, SLOT(slotUser1()) );
179  connect( this, SIGNAL(user2Clicked()), this, SLOT(slotUser2()) );
180  enableButton( User1, false );
181  enableButton( User2, false );
182 }
183 
184 RedirectDialog::~RedirectDialog()
185 {
186  delete d;
187 }
188 
189 QString RedirectDialog::to() const
190 {
191  return d->mEditTo->resend();
192 }
193 
194 QString RedirectDialog::cc() const
195 {
196  return d->mEditCc->resend();
197 }
198 
199 QString RedirectDialog::bcc() const
200 {
201  return d->mEditBcc->resend();
202 }
203 
204 RedirectDialog::SendMode RedirectDialog::sendMode() const
205 {
206  return d->mSendMode;
207 }
208 
209 int RedirectDialog::transportId() const
210 {
211  return d->mTransportCombobox->currentTransportId();
212 }
213 
214 int RedirectDialog::identity() const
215 {
216  return static_cast<int>(d->mComboboxIdentity->currentIdentity());
217 }
218 
219 void RedirectDialog::accept()
220 {
221  const QString editTo = d->mEditTo->resend();
222  if ( editTo.isEmpty() ) {
223  KMessageBox::sorry(
224  this,
225  i18n( "You cannot redirect the message without an address." ),
226  i18n( "Empty Redirection Address" ) );
227  } else {
228  done( Ok );
229  }
230 }
231 
232 #include "moc_redirectdialog.cpp"
MailCommon::RedirectDialog
A dialog to request information about message redirection from the user.
Definition: redirectdialog.h:46
MailCommon::RedirectDialog::to
QString to() const
Returns the addresses for the redirection.
Definition: redirectdialog.cpp:189
MailCommon::RedirectDialog::accept
virtual void accept()
Definition: redirectdialog.cpp:219
QWidget
KernelIf
#define KernelIf
Definition: mailkernel.h:191
text
const char * text
Definition: mdnadvicedialog.cpp:54
MailCommon::RedirectDialog::cc
QString cc() const
Definition: redirectdialog.cpp:194
MailCommon::RedirectWidget
Definition: redirectwidget.h:33
QHBoxLayout
MailCommon::RedirectDialog::transportId
int transportId() const
Definition: redirectdialog.cpp:209
KDialog
MailCommon::RedirectDialog::SendLater
Definition: redirectdialog.h:56
QLabel::setBuddy
void setBuddy(QWidget *buddy)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QWidget::setLayout
void setLayout(QLayout *layout)
MailCommon::RedirectDialog::sendMode
SendMode sendMode() const
Returns the send mode.
Definition: redirectdialog.cpp:204
QString::isEmpty
bool isEmpty() const
QString::trimmed
QString trimmed() const
QVBoxLayout
MailCommon::RedirectDialog::SendMode
SendMode
Describes the send mode.
Definition: redirectdialog.h:54
QString
redirectdialog.h
MailCommon::RedirectDialog::RedirectDialog
RedirectDialog(SendMode mode=SendNow, QWidget *parent=0)
Creates a new redirect dialog.
Definition: redirectdialog.cpp:130
QFormLayout::addRow
void addRow(QWidget *label, QWidget *field)
QLatin1String
mailkernel.h
redirectwidget.h
MailCommon::RedirectDialog::bcc
QString bcc() const
Definition: redirectdialog.cpp:199
MailCommon::RedirectDialog::SendNow
Definition: redirectdialog.h:55
QLabel
MailCommon::RedirectDialog::~RedirectDialog
~RedirectDialog()
Destroys the redirect dialog.
Definition: redirectdialog.cpp:184
QBoxLayout::setSpacing
void setSpacing(int spacing)
MailCommon::RedirectDialog::identity
int identity() const
Definition: redirectdialog.cpp:214
QBoxLayout::addLayout
void addLayout(QLayout *layout, int stretch)
QFormLayout
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:40 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
  • pimprint

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