• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 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
26using namespace MailTransport;
27
32class TransportComboBoxPrivate
33{
34 public:
35 QList<int> transports;
36};
37
38TransportComboBox::TransportComboBox( QWidget *parent )
39 : KComboBox( parent ), d( new TransportComboBoxPrivate )
40{
41 QMetaObject::invokeMethod(this, "updateComboboxList");
42 connect( TransportManager::self(), SIGNAL(transportsChanged()),
43 SLOT(updateComboboxList()) );
44}
45
46TransportComboBox::~TransportComboBox()
47{
48 delete d;
49}
50
51int TransportComboBox::currentTransportId() const
52{
53 if ( currentIndex() >= 0 && currentIndex() < d->transports.count() ) {
54 return d->transports.at( currentIndex() );
55 }
56 return -1;
57}
58
59void TransportComboBox::setCurrentTransport( int transportId )
60{
61 const int i = d->transports.indexOf( transportId );
62 if ( i >= 0 && i < count() ) {
63 setCurrentIndex( i );
64 }
65}
66
67TransportBase::EnumType::type TransportComboBox::transportType() const
68{
69 int transtype = TransportManager::self()->transportById( currentTransportId() )->type();
70 return static_cast<TransportBase::EnumType::type>( transtype );
71}
72
73void TransportComboBox::updateComboboxList()
74{
75 fillComboBox();
76}
77
78void TransportComboBox::fillComboBox()
79{
80 const int oldTransport = currentTransportId();
81 clear();
82
83 int defaultId = 0;
84 if ( !TransportManager::self()->isEmpty() ) {
85 const QStringList listNames = TransportManager::self()->transportNames();
86 const QList<int> listIds = TransportManager::self()->transportIds();
87 addItems( listNames );
88 setTransportList(listIds);
89 defaultId = TransportManager::self()->defaultTransportId();
90 }
91
92 if ( oldTransport != -1 ) {
93 setCurrentTransport( oldTransport );
94 } else {
95 setCurrentTransport( defaultId );
96 }
97}
98
99void TransportComboBox::setTransportList(const QList<int> &transportList)
100{
101 d->transports = transportList;
102}
MailTransport::TransportComboBox::transportType
TransportBase::EnumType::type transportType() const
Returns the type of the selected transport.
Definition transportcombobox.cpp:67
MailTransport::TransportComboBox::setCurrentTransport
void setCurrentTransport(int transportId)
Selects the given transport.
Definition transportcombobox.cpp:59
MailTransport::TransportComboBox::TransportComboBox
TransportComboBox(QWidget *parent=0)
Creates a new mail transport selection combo box.
Definition transportcombobox.cpp:38
MailTransport::TransportComboBox::currentTransportId
int currentTransportId() const
Returns identifier of the currently selected mail transport.
Definition transportcombobox.cpp:51
MailTransport::TransportComboBox::updateComboboxList
void updateComboboxList()
Definition transportcombobox.cpp:73
MailTransport::TransportManager::transportById
Transport * transportById(int id, bool def=true) const
Returns the Transport object with the given id.
Definition transportmanager.cpp:171
MailTransport::TransportManager::transportNames
Q_SCRIPTABLE QStringList transportNames() const
Returns a list of transport names.
Definition transportmanager.cpp:358
MailTransport::TransportManager::self
static TransportManager * self()
Returns the TransportManager instance.
Definition transportmanager.cpp:162
MailTransport::TransportManager::defaultTransportId
Q_SCRIPTABLE int defaultTransportId() const
Returns the default transport identifier.
Definition transportmanager.cpp:376
MailTransport::TransportManager::transportIds
Q_SCRIPTABLE QList< int > transportIds() const
Returns a list of transport identifiers.
Definition transportmanager.cpp:349
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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.14.10 API Reference

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