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

kabc

  • kabc
  • plugins
  • net
resourcenetconfig.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "resourcenetconfig.h"
22 #include "resourcenet.h"
23 
24 #include "kabc/formatfactory.h"
25 #include "kabc/stdaddressbook.h"
26 
27 #include <kdebug.h>
28 #include <klocale.h>
29 #include <kdialog.h>
30 
31 #include <QFormLayout>
32 
33 using namespace KABC;
34 
35 ResourceNetConfig::ResourceNetConfig( QWidget *parent )
36  : ConfigWidget( parent ), mInEditMode( false )
37 {
38  QFormLayout *mainLayout = new QFormLayout( this );
39  mainLayout->setMargin( 0 );
40 
41  mFormatBox = new KComboBox( this );
42 
43  mainLayout->addRow( i18n( "Format:" ), mFormatBox );
44 
45  mUrlEdit = new KUrlRequester( this );
46  mUrlEdit->setMode( KFile::File );
47 
48  mainLayout->addRow( i18n( "Location:" ), mUrlEdit );
49 
50  FormatFactory *factory = FormatFactory::self();
51  QStringList formats = factory->formats();
52  QStringList::Iterator it;
53  for ( it = formats.begin(); it != formats.end(); ++it ) {
54  FormatInfo info = factory->info( *it );
55  if ( !info.isNull() ) {
56  mFormatTypes << ( *it );
57  mFormatBox->addItem( info.nameLabel );
58  }
59  }
60 }
61 
62 void ResourceNetConfig::setEditMode( bool value )
63 {
64  mFormatBox->setEnabled( !value );
65  mInEditMode = value;
66 }
67 
68 void ResourceNetConfig::loadSettings( KRES::Resource *res )
69 {
70  ResourceNet *resource = dynamic_cast<ResourceNet*>( res );
71 
72  if ( !resource ) {
73  kDebug() << "cast failed";
74  return;
75  }
76 
77  mFormatBox->setCurrentIndex( mFormatTypes.indexOf( resource->format() ) );
78 
79  mUrlEdit->setUrl( resource->url() );
80 }
81 
82 void ResourceNetConfig::saveSettings( KRES::Resource *res )
83 {
84  ResourceNet *resource = dynamic_cast<ResourceNet*>( res );
85 
86  if ( !resource ) {
87  kDebug() << "cast failed";
88  return;
89  }
90 
91  if ( !mInEditMode ) {
92  resource->setFormat( mFormatTypes[ mFormatBox->currentIndex() ] );
93  }
94 
95  resource->setUrl( KUrl( mUrlEdit->url() ) );
96 }
97 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:29:42 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • 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