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

mailtransport

  • mailtransport
transportmanagementwidget.cpp
1 /*
2  Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
3 
4  Based on KMail code by:
5  Copyright (C) 2001-2003 Marc Mutz <mutz@kde.org>
6 
7  This library is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Library General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15  License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to the
19  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  02110-1301, USA.
21 */
22 
23 #include "transportmanagementwidget.h"
24 #include "ui_transportmanagementwidget.h"
25 #include "transportmanager.h"
26 #include "transport.h"
27 
28 #include <KMessageBox>
29 
30 using namespace MailTransport;
31 
32 class TransportManagementWidget::Private
33 {
34  public:
35 
36  Private( TransportManagementWidget *parent );
37 
38  Ui::TransportManagementWidget ui;
39  TransportManagementWidget *q;
40 
41  // Slots
42  void defaultClicked();
43  void removeClicked();
44  void renameClicked();
45  void editClicked();
46  void addClicked();
47  void updateButtonState();
48 };
49 
50 TransportManagementWidget::Private::Private( TransportManagementWidget *parent )
51  : q( parent )
52 {
53 }
54 
55 TransportManagementWidget::TransportManagementWidget( QWidget *parent )
56  : QWidget( parent ), d( new Private( this ) )
57 {
58  KGlobal::locale()->insertCatalog( QString::fromLatin1( "libmailtransport" ) );
59  d->ui.setupUi( this );
60  d->updateButtonState();
61 
62  connect( d->ui.transportList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
63  SLOT(updateButtonState()) );
64  connect( d->ui.transportList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
65  SLOT(editClicked()) );
66  connect( d->ui.addButton, SIGNAL(clicked()), SLOT(addClicked()) );
67  connect( d->ui.editButton, SIGNAL(clicked()), SLOT(editClicked()) );
68  connect( d->ui.renameButton, SIGNAL(clicked()), SLOT(renameClicked()) );
69  connect( d->ui.removeButton, SIGNAL(clicked()), SLOT(removeClicked()) );
70  connect( d->ui.defaultButton, SIGNAL(clicked()), SLOT(defaultClicked()) );
71 }
72 
73 TransportManagementWidget::~TransportManagementWidget()
74 {
75  delete d;
76 }
77 
78 void TransportManagementWidget::Private::updateButtonState()
79 {
80  // TODO figure out current item vs. selected item (in almost every function)
81  if ( !ui.transportList->currentItem() ) {
82  ui.editButton->setEnabled( false );
83  ui.renameButton->setEnabled( false );
84  ui.removeButton->setEnabled( false );
85  ui.defaultButton->setEnabled( false );
86  } else {
87  ui.editButton->setEnabled( true );
88  ui.renameButton->setEnabled( true );
89  ui.removeButton->setEnabled( true );
90  if ( ui.transportList->currentItem()->data( 0, Qt::UserRole ) ==
91  TransportManager::self()->defaultTransportId() ) {
92  ui.defaultButton->setEnabled( false );
93  } else {
94  ui.defaultButton->setEnabled( true );
95  }
96  }
97 }
98 
99 void TransportManagementWidget::Private::addClicked()
100 {
101  TransportManager::self()->showTransportCreationDialog( q );
102 }
103 
104 void TransportManagementWidget::Private::editClicked()
105 {
106  if( !ui.transportList->currentItem() ) {
107  return;
108  }
109 
110  int currentId = ui.transportList->currentItem()->data( 0, Qt::UserRole ).toInt();
111  Transport *transport = TransportManager::self()->transportById( currentId );
112  TransportManager::self()->configureTransport( transport, q );
113 }
114 
115 void TransportManagementWidget::Private::renameClicked()
116 {
117  if( !ui.transportList->currentItem() ) {
118  return;
119  }
120 
121  ui.transportList->editItem( ui.transportList->currentItem(), 0 );
122 }
123 
124 void TransportManagementWidget::Private::removeClicked()
125 {
126  if( !ui.transportList->currentItem() ) {
127  return;
128  }
129  const int rc =
130  KMessageBox::questionYesNo(
131  q,
132  i18n( "Do you want to remove outgoing account '%1'?",
133  ui.transportList->currentItem()->text( 0 ) ),
134  i18n( "Remove outgoing account?" ) );
135  if ( rc == KMessageBox::No ) {
136  return;
137  }
138 
139  TransportManager::self()->removeTransport(
140  ui.transportList->currentItem()->data( 0, Qt::UserRole ).toInt() );
141 }
142 
143 void TransportManagementWidget::Private::defaultClicked()
144 {
145  if( !ui.transportList->currentItem() ) {
146  return;
147  }
148 
149  TransportManager::self()->setDefaultTransport(
150  ui.transportList->currentItem()->data( 0, Qt::UserRole ).toInt() );
151 }
152 
153 #include "transportmanagementwidget.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Wed Nov 28 2012 21:49:12 by doxygen 1.8.1.2 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.9.3 API Reference

Skip menu "kdepimlibs-4.9.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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