• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 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 <KLocale>
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  fillComboBox();
43  connect( TransportManager::self(), SIGNAL(transportsChanged()),
44  SLOT(fillComboBox()) );
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::fillComboBox()
75 {
76  const int oldTransport = currentTransportId();
77  clear();
78  d->transports.clear();
79 
80  int defaultId = 0;
81  if ( !TransportManager::self()->isEmpty() ) {
82  QStringList listNames = TransportManager::self()->transportNames();
83  QList<int> listIds = TransportManager::self()->transportIds();
84  addItems( listNames );
85  d->transports << listIds;
86  defaultId = TransportManager::self()->defaultTransportId();
87  }
88 
89  if ( oldTransport != -1 ) {
90  setCurrentTransport( oldTransport );
91  } else {
92  setCurrentTransport( defaultId );
93  }
94 }
95 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:26:53 by doxygen 1.8.3.1 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.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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