# kabc Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# resourcedirconfig.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 "resourcedirconfig.h"
    00029 #include "stdaddressbook.h"
    00030
    00031 using namespace KABC;
    00032
    00033 ResourceDirConfig::ResourceDirConfig( QWidget* parent,  const char* name )
    00034     : ResourceConfigWidget( parent, name )
    00035 {
    00036   resize( 245, 115 );
    00037   QGridLayout *mainLayout = new QGridLayout( this, 2, 2 );
    00038
    00039   QLabel *label = new QLabel( i18n( "Format:" ), this );
    00040   mFormatBox = new KComboBox( this );
    00041
    00042   mainLayout->addWidget( label, 0, 0 );
    00043   mainLayout->addWidget( mFormatBox, 0, 1 );
    00044
    00045   label = new QLabel( i18n( "Location:" ), this );
    00046   mFileNameEdit = new KURLRequester( this );
    00047   mFileNameEdit->setMode( KFile::Directory );
    00048
    00049   mainLayout->addWidget( label, 1, 0 );
    00050   mainLayout->addWidget( mFileNameEdit, 1, 1 );
    00051
    00052   FormatFactory *factory = FormatFactory::self();
    00053   QStringList formats = factory->formats();
    00054   QStringList::Iterator it;
    00055   for ( it = formats.begin(); it != formats.end(); ++it ) {
    00056     FormatInfo *info = factory->info( *it );
    00057     if ( info ) {
    00058       mFormatTypes << (*it);
    00059       mFormatBox->insertItem( info->nameLabel );
    00060     }
    00061   }
    00062 }
    00063
    00064 void ResourceDirConfig::setEditMode( bool value )
    00065 {
    00066   mFormatBox->setEnabled( !value );
    00067 }
    00068
    00069 void ResourceDirConfig::loadSettings( KConfig *config )
    00070 {
    00071   QString format = config->readEntry( "FileFormat" );
    00072   mFormatBox->setCurrentItem( mFormatTypes.findIndex( format ) );
    00073
    00074   mFileNameEdit->setURL( config->readPathEntry( "FilePath" ) );
    00075   if ( mFileNameEdit->url().isEmpty() )
    00076     mFileNameEdit->setURL( KABC::StdAddressBook::directoryName() );
    00077 }
    00078
    00079 void ResourceDirConfig::saveSettings( KConfig *config )
    00080 {
    00081   config->writeEntry( "FileFormat", mFormatTypes[ mFormatBox->currentItem() ] );
    00082   config->writeEntry( "FilePath", mFileNameEdit->url() );
    00083 }
    00084
    00085 #include "resourcedirconfig.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