• 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
redirectwidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2015 Montel Laurent <montel@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 
19 */
20 
21 #include "redirectwidget.h"
22 #include "kernel/mailkernel.h"
23 
24 #include <QTreeView>
25 
26 #include <messagecomposer/composer/composerlineedit.h>
27 
28 #include <messageviewer/utils/autoqpointer.h>
29 
30 #include <Akonadi/Contact/EmailAddressSelectionDialog>
31 
32 #include <KIcon>
33 #include <QHBoxLayout>
34 #include <QPushButton>
35 #include <KLocalizedString>
36 
37 using namespace MailCommon;
38 
39 RedirectWidget::RedirectWidget(QWidget *parent)
40  : QWidget(parent)
41 {
42  QHBoxLayout *hbox = new QHBoxLayout;
43  hbox->setSpacing( 0 );
44  hbox->setMargin( 0 );
45  hbox->setAlignment(Qt::AlignRight);
46  setLayout(hbox);
47 
48  mEdit = new MessageComposer::ComposerLineEdit( true );
49  mEdit->setRecentAddressConfig( KernelIf->config().data() );
50  mEdit->setMinimumWidth( 300 );
51  mEdit->setClearButtonShown( true );
52  hbox->addWidget(mEdit);
53 
54  QPushButton *BtnTo = new QPushButton( QString() );
55  BtnTo->setIcon( KIcon( QLatin1String("help-contents") ) );
56  BtnTo->setIconSize( QSize( KIconLoader::SizeSmall, KIconLoader::SizeSmall ) );
57  BtnTo->setMinimumSize( BtnTo->sizeHint() * 1.2 );
58  BtnTo->setToolTip( i18n( "Use the Address-Selection Dialog" ) );
59  BtnTo->setWhatsThis( i18n( "This button opens a separate dialog "
60  "where you can select recipients out "
61  "of all available addresses." ) );
62  hbox->addWidget(BtnTo);
63  connect( BtnTo, SIGNAL(clicked()), SLOT(slotAddressSelection()) );
64 
65  connect( mEdit, SIGNAL(textChanged(QString)), SIGNAL(addressChanged(QString)) );
66 }
67 
68 RedirectWidget::~RedirectWidget()
69 {
70 
71 }
72 
73 QString RedirectWidget::resend()
74 {
75  mResendStr = mEdit->text();
76  return mResendStr;
77 }
78 
79 void RedirectWidget::setFocus()
80 {
81  mEdit->setFocus();
82 }
83 
84 void RedirectWidget::slotAddressSelection()
85 {
86  MessageViewer::AutoQPointer<Akonadi::EmailAddressSelectionDialog> dlg(
87  new Akonadi::EmailAddressSelectionDialog( this ) );
88 
89  dlg->view()->view()->setSelectionMode( QAbstractItemView::MultiSelection );
90 
91  mResendStr = mEdit->text();
92 
93  if ( dlg->exec() != KDialog::Rejected && dlg ) {
94  QStringList addresses;
95  foreach ( const Akonadi::EmailAddressSelection &selection, dlg->selectedAddresses() ) {
96  addresses << selection.quotedEmail();
97  }
98 
99  if ( !mResendStr.isEmpty() ) {
100  addresses.prepend( mResendStr );
101  }
102 
103  mEdit->setText( addresses.join( QLatin1String(", ") ) );
104  mEdit->setModified( true );
105  }
106 }
QWidget
KernelIf
#define KernelIf
Definition: mailkernel.h:191
QPushButton::sizeHint
virtual QSize sizeHint() const
MailCommon::RedirectWidget::RedirectWidget
RedirectWidget(QWidget *parent=0)
Definition: redirectwidget.cpp:39
MailCommon::RedirectWidget::setFocus
void setFocus()
Definition: redirectwidget.cpp:79
QHBoxLayout
QStringList::join
QString join(const QString &separator) const
QAbstractButton::setIcon
void setIcon(const QIcon &icon)
MailCommon::RedirectWidget::~RedirectWidget
~RedirectWidget()
Definition: redirectwidget.cpp:68
QWidget::setMinimumSize
void setMinimumSize(const QSize &)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QWidget::setLayout
void setLayout(QLayout *layout)
QAbstractButton::setIconSize
void setIconSize(const QSize &size)
QString::isEmpty
bool isEmpty() const
QString
QLayout::setMargin
void setMargin(int margin)
MailCommon::RedirectWidget::addressChanged
void addressChanged(const QString &)
QStringList
QSize
QLayout::setAlignment
bool setAlignment(QWidget *w, QFlags< Qt::AlignmentFlag > alignment)
QWidget::setWhatsThis
void setWhatsThis(const QString &)
MailCommon::RedirectWidget::resend
QString resend()
Definition: redirectwidget.cpp:73
QLatin1String
mailkernel.h
redirectwidget.h
QPushButton
QList::prepend
void prepend(const T &value)
QWidget::setToolTip
void setToolTip(const QString &)
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QBoxLayout::setSpacing
void setSpacing(int spacing)
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