• Skip to content
  • Skip to link menu
KDE 4.7 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

kabc

resourcenetconfig.cpp
00001 /*
00002     This file is part of libkabc.
00003     Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "resourcenetconfig.h"
00022 #include "resourcenet.h"
00023 
00024 #include "kabc/formatfactory.h"
00025 #include "kabc/stdaddressbook.h"
00026 
00027 #include <kdebug.h>
00028 #include <klocale.h>
00029 #include <kdialog.h>
00030 
00031 #include <QtGui/QFormLayout>
00032 
00033 using namespace KABC;
00034 
00035 ResourceNetConfig::ResourceNetConfig( QWidget *parent )
00036     : ConfigWidget( parent ), mInEditMode( false )
00037 {
00038   QFormLayout *mainLayout = new QFormLayout( this );
00039   mainLayout->setMargin( 0 );
00040 
00041   mFormatBox = new KComboBox( this );
00042 
00043   mainLayout->addRow( i18n( "Format:" ), mFormatBox );
00044 
00045   mUrlEdit = new KUrlRequester( this );
00046   mUrlEdit->setMode( KFile::File );
00047 
00048   mainLayout->addRow( i18n( "Location:" ), mUrlEdit );
00049 
00050   FormatFactory *factory = FormatFactory::self();
00051   QStringList formats = factory->formats();
00052   QStringList::Iterator it;
00053   for ( it = formats.begin(); it != formats.end(); ++it ) {
00054     FormatInfo info = factory->info( *it );
00055     if ( !info.isNull() ) {
00056       mFormatTypes << (*it);
00057       mFormatBox->addItem( info.nameLabel );
00058     }
00059   }
00060 }
00061 
00062 void ResourceNetConfig::setEditMode( bool value )
00063 {
00064   mFormatBox->setEnabled( !value );
00065   mInEditMode = value;
00066 }
00067 
00068 void ResourceNetConfig::loadSettings( KRES::Resource *res )
00069 {
00070   ResourceNet *resource = dynamic_cast<ResourceNet*>( res );
00071 
00072   if ( !resource ) {
00073     kDebug() << "cast failed";
00074     return;
00075   }
00076 
00077   mFormatBox->setCurrentIndex( mFormatTypes.indexOf( resource->format() ) );
00078 
00079   mUrlEdit->setUrl( resource->url() );
00080 }
00081 
00082 void ResourceNetConfig::saveSettings( KRES::Resource *res )
00083 {
00084   ResourceNet *resource = dynamic_cast<ResourceNet*>( res );
00085 
00086   if ( !resource ) {
00087     kDebug() << "cast failed";
00088     return;
00089   }
00090 
00091   if ( !mInEditMode ) {
00092     resource->setFormat( mFormatTypes[ mFormatBox->currentIndex() ] );
00093   }
00094 
00095   resource->setUrl( KUrl( mUrlEdit->url() ) );
00096 }
00097 
00098 #include "resourcenetconfig.moc"

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • 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
Generated for KDE-PIM Libraries by doxygen 1.7.5
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