• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.11.3 API Reference
  • KDE Home
  • Contact Us
 

mailtransport

  • mailtransport
transportcombobox.cpp
1 /*
2  Copyright (c) 2006 - 2007 Volker Krause <vkrause@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 #include "transportcombobox.h"
21 #include "transport.h"
22 #include "transportmanager.h"
23 
24 #include <KDebug>
25 #include <KLocalizedString>
26 
27 using namespace MailTransport;
28 
33 class TransportComboBoxPrivate
34 {
35  public:
36  QList<int> transports;
37 };
38 
39 TransportComboBox::TransportComboBox( QWidget *parent )
40  : KComboBox( parent ), d( new TransportComboBoxPrivate )
41 {
42  QMetaObject::invokeMethod(this, "updateComboboxList");
43  connect( TransportManager::self(), SIGNAL(transportsChanged()),
44  SLOT(updateComboboxList()) );
45 }
46 
47 TransportComboBox::~TransportComboBox()
48 {
49  delete d;
50 }
51 
52 int TransportComboBox::currentTransportId() const
53 {
54  if ( currentIndex() >= 0 && currentIndex() < d->transports.count() ) {
55  return d->transports.at( currentIndex() );
56  }
57  return -1;
58 }
59 
60 void TransportComboBox::setCurrentTransport( int transportId )
61 {
62  const int i = d->transports.indexOf( transportId );
63  if ( i >= 0 && i < count() ) {
64  setCurrentIndex( i );
65  }
66 }
67 
68 TransportBase::EnumType::type TransportComboBox::transportType() const
69 {
70  int transtype = TransportManager::self()->transportById( currentTransportId() )->type();
71  return static_cast<TransportBase::EnumType::type>( transtype );
72 }
73 
74 void TransportComboBox::updateComboboxList()
75 {
76  fillComboBox();
77 }
78 
79 void TransportComboBox::fillComboBox()
80 {
81  const int oldTransport = currentTransportId();
82  clear();
83 
84  int defaultId = 0;
85  if ( !TransportManager::self()->isEmpty() ) {
86  const QStringList listNames = TransportManager::self()->transportNames();
87  const QList<int> listIds = TransportManager::self()->transportIds();
88  addItems( listNames );
89  setTransportList(listIds);
90  defaultId = TransportManager::self()->defaultTransportId();
91  }
92 
93  if ( oldTransport != -1 ) {
94  setCurrentTransport( oldTransport );
95  } else {
96  setCurrentTransport( defaultId );
97  }
98 }
99 
100 void TransportComboBox::setTransportList(const QList<int> &transportList)
101 {
102  d->transports = transportList;
103 }
MailTransport::TransportComboBox::transportType
TransportBase::EnumType::type transportType() const
Returns the type of the selected transport.
Definition: transportcombobox.cpp:68
MailTransport::TransportManager::self
static TransportManager * self()
Returns the TransportManager instance.
Definition: transportmanager.cpp:163
MailTransport::TransportManager::defaultTransportId
Q_SCRIPTABLE int defaultTransportId() const
Returns the default transport identifier.
Definition: transportmanager.cpp:377
MailTransport::TransportManager::transportNames
Q_SCRIPTABLE QStringList transportNames() const
Returns a list of transport names.
Definition: transportmanager.cpp:359
MailTransport::TransportComboBox::TransportComboBox
TransportComboBox(QWidget *parent=0)
Creates a new mail transport selection combo box.
Definition: transportcombobox.cpp:39
MailTransport::TransportComboBox::updateComboboxList
void updateComboboxList()
Definition: transportcombobox.cpp:74
MailTransport::TransportComboBox::currentTransportId
int currentTransportId() const
Returns identifier of the currently selected mail transport.
Definition: transportcombobox.cpp:52
MailTransport::TransportManager::transportIds
Q_SCRIPTABLE QList< int > transportIds() const
Returns a list of transport identifiers.
Definition: transportmanager.cpp:350
MailTransport::TransportComboBox::setCurrentTransport
void setCurrentTransport(int transportId)
Selects the given transport.
Definition: transportcombobox.cpp:60
MailTransport::TransportManager::transportById
Transport * transportById(int id, bool def=true) const
Returns the Transport object with the given id.
Definition: transportmanager.cpp:172
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:03:01 by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailtransport

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

kdepimlibs-4.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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