• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

mailtransport

transportcombobox.cpp

00001 /*
00002     Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "transportcombobox.h"
00021 #include "transport.h"
00022 #include "transportmanager.h"
00023 
00024 #include <kdebug.h>
00025 #include <klocale.h>
00026 
00027 #include <QLineEdit>
00028 
00029 using namespace MailTransport;
00030 
00035 class TransportComboBoxPrivate
00036 {
00037   public:
00038     QList<int> transports;
00039 };
00040 
00041 TransportComboBox::TransportComboBox( QWidget *parent )
00042   : KComboBox( parent ), d( new TransportComboBoxPrivate )
00043 {
00044   fillComboBox();
00045   connect( TransportManager::self(), SIGNAL(transportsChanged()),
00046            SLOT(fillComboBox()) );
00047 }
00048 
00049 TransportComboBox::~TransportComboBox()
00050 {
00051    delete d;
00052 }
00053 
00054 int TransportComboBox::currentTransportId() const
00055 {
00056   if ( currentIndex() >= 0 && currentIndex() < d->transports.count() ) {
00057     return d->transports.at( currentIndex() );
00058   }
00059   return -1;
00060 }
00061 
00062 void TransportComboBox::setCurrentTransport( int transportId )
00063 {
00064   int i = d->transports.indexOf( transportId );
00065   if ( i >= 0 && i < count() ) {
00066     setCurrentIndex( i );
00067   }
00068 }
00069 
00070 TransportBase::EnumType::type TransportComboBox::transportType() const
00071 {
00072   int transtype = TransportManager::self()->transportById( currentTransportId() )->type();
00073   return static_cast<TransportBase::EnumType::type>( transtype );
00074 }
00075 
00076 void TransportComboBox::fillComboBox()
00077 {
00078   int oldTransport = currentTransportId();
00079   clear();
00080   d->transports.clear();
00081 
00082   int defaultId = 0;
00083   if ( !TransportManager::self()->isEmpty() ) {
00084     QStringList listNames = TransportManager::self()->transportNames();
00085     QList<int> listIds = TransportManager::self()->transportIds();
00086     addItems( listNames );
00087     d->transports << listIds;
00088     defaultId = TransportManager::self()->defaultTransportId();
00089   }
00090 
00091   if ( oldTransport != -1 ) {
00092     setCurrentTransport( oldTransport );
00093   } else {
00094     setCurrentTransport( defaultId );
00095   }
00096 }
00097 
00098 #include "transportcombobox.moc"

mailtransport

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.8
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal