resourcenetconfig.cpp Source File (kabc Library)

| # kabc Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# resourcenetconfig.cpp

    00001 /*
    00002     This file is part of libkabc.
    00003     Copyright (c) 2002 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., 59 Temple Place - Suite 330,
    00018     Boston, MA 02111-1307, USA.
    00019 */
    00020
    00021 #include <qlabel.h>
    00022 #include <qlayout.h>
    00023
    00024 #include <klocale.h>
    00025 #include <kstandarddirs.h>
    00026
    00027 #include "formatfactory.h"
    00028 #include "stdaddressbook.h"
    00029
    00030 #include "resourcenetconfig.h"
    00031
    00032 using namespace KABC;
    00033
    00034 ResourceNetConfig::ResourceNetConfig( QWidget* parent,  const char* name )
    00035     : ResourceConfigWidget( parent, name )
    00036 {
    00037   resize( 245, 115 );
    00038   QGridLayout *mainLayout = new QGridLayout( this, 2, 2 );
    00039
    00040   QLabel *label = new QLabel( i18n( "Format:" ), this );
    00041   mFormatBox = new KComboBox( this );
    00042
    00043   mainLayout->addWidget( label, 0, 0 );
    00044   mainLayout->addWidget( mFormatBox, 0, 1 );
    00045
    00046   label = new QLabel( i18n( "Location:" ), this );
    00047   mUrlEdit = new KURLRequester( this );
    00048   mUrlEdit->setMode( KFile::Directory );
    00049
    00050   mainLayout->addWidget( label, 1, 0 );
    00051   mainLayout->addWidget( mUrlEdit, 1, 1 );
    00052
    00053   FormatFactory *factory = FormatFactory::self();
    00054   QStringList formats = factory->formats();
    00055   QStringList::Iterator it;
    00056   for ( it = formats.begin(); it != formats.end(); ++it ) {
    00057     FormatInfo *info = factory->info( *it );
    00058     if ( info ) {
    00059       mFormatTypes << (*it);
    00060       mFormatBox->insertItem( info->nameLabel );
    00061     }
    00062   }
    00063 }
    00064
    00065 void ResourceNetConfig::loadSettings( KConfig *config )
    00066 {
    00067   QString format = config->readEntry( "NetFormat" );
    00068   mFormatBox->setCurrentItem( mFormatTypes.findIndex( format ) );
    00069
    00070   mUrlEdit->setURL( config->readPathEntry( "NetUrl" ) );
    00071   if ( mUrlEdit->url().isEmpty() )
    00072     mUrlEdit->setURL( KABC::StdAddressBook::directoryName() );
    00073 }
    00074
    00075 void ResourceNetConfig::saveSettings( KConfig *config )
    00076 {
    00077   config->writeEntry( "NetFormat", mFormatTypes[ mFormatBox->currentItem() ] );
    00078   config->writeEntry( "NetUrl", mUrlEdit->url() );
    00079 }
    00080
    00081 #include "resourcenetconfig.moc"

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:29:21 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001